package com.itheima.stock.job.jobhandler;

import com.itheima.stock.job.service.StockTimerService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.ParseException;

/**
 * 定义股票相关数据的定时任务
 * @author laofang
 */
@Component
public class StockJob {
    @Autowired
    private StockTimerService stockTimerService;
    private static Logger logger = LoggerFactory.getLogger(StockJob.class);

    @XxlJob("hema_job_test")
    public void jobTest(){
        System.out.println("jobTest run.....");
    }
    @XxlJob("stock_RT")
    public void getStockRtInfoTask() throws ParseException {
        stockTimerService.insertRTBatch();
    }
    /**
     * 板块定时任务
     */
    @XxlJob("stock_block")
    public void getStockBlockInfoTask(){
        stockTimerService.getStockSectorRtIndex();
    }
    @XxlJob("stock_detailsBatch")
    public void getRtgegubatch(){
        stockTimerService.getRtgegubatch();
    }

    /**
     * 批量个股开盘不能拉取
     */
    @XxlJob("stock_code")
    public void getStockRtIndex(){
        stockTimerService.getStockRtIndex();
    }

    /**
     * 大盘定时任务
     * @throws ParseException
     */
    @XxlJob("stock_dapan")
    public void getdapan() throws ParseException {
        stockTimerService.insertBatch();
    }
    @XxlJob("stock_ourdapan")
    public void getour(){
        stockTimerService.gtOuterMarkInfo();
    }

    public void init(){
        logger.info("init");
    }

    public void destroy(){
        logger.info("destory");
    }
}